package cn.edu.bupt.iocaop.demo.controller;

import cn.edu.bupt.iocaop.demo.service.TestService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Scope;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
//Controller作用域默认为singleton
//@Scope("prototype")
//@Scope("session")
public class TestController {
    @Autowired
    private TestService testService;
    private static int static_var = 0; //静态的
    private int local_var = 0;        //非静态

    @GetMapping("/save")
    public String save() {
        testService.save();
        System.out.println(this+" :testController Save");
        System.out.println("static_var:" + static_var++ + " | local_var:" + local_var++);
        return "save done";
    }
}
